package com.kingsoft.minibase;

import java.io.IOException;

public interface MiniBase {
    void put(byte[] key, byte[] value) throws IOException;

    KeyValue get(byte[] key) throws IOException;

    void delete(byte[] key) throws IOException;

    Iter<KeyValue> scan(byte[] startKey, byte[] stopKey) throws IOException;

    default Iter<KeyValue> scan() throws IOException {
        return scan(Bytes.EMPTY_BYTES, Bytes.EMPTY_BYTES);
    }

    interface Iter<KeyValue> {
        boolean hasNest() throws IOException;
        KeyValue next() throws IOException;
    }

    interface Flusher {
        void flush(Iter<KeyValue> iter) throws IOException;
    }

    abstract class Compactor extends Thread {
        public abstract void compact() throws IOException;
    }
}
